#include "StdAfx.h"
#include "LineEditor.h"
#include "EditorHelper.h"
#include "./FunctionDrivers/FunctionDriverLine.h"
#include "LabelTools.h"
#include "LineBuilder.h"

REGISTERE_EDITOR(CLineEditor);

CLineEditor::CLineEditor(void)
{

}

CLineEditor::~CLineEditor(void)
{

}

CString CLineEditor::GetID(void)
{
	return LINE_TWO_CUID;
}

CLineInfo* CLineEditor::GetShapeInfo()
{
	return &m_Info;
}
void CLineEditor::Initialize(CAnyView* pView)
{
	m_Info.Reset();

	AddSubEditor(new CPointCapture(m_Info.ptStart), CLineInfo::START_POINT);
	AddSubEditor(new CPointCapture(m_Info.ptEnd), CLineInfo::END_POINT);

	CModelEditor::Initialize(pView);
}

bool CLineEditor::CreatePreviewShape(void)
{
	if(CurrentStep() == CLineInfo::START_POINT)
		return false;

	TopoDS_Shape shape;
	CLineBuilder builder;
	if(builder.Build(&m_Info, shape))
	{
		SetPreviewShape(shape);
		return true;
	}

	return false;
}

bool CLineEditor::CreateShapeLabel(TDF_Label& label)
{
	label = NewLabel(_T("Line"));

	m_Info.AddToLabel(label);

	Handle(CFunctionDriverLine) functionDriver;
	return ProcessFunctionDriver<CFunctionDriverLine>(label, functionDriver);
}

//////////////////////////////////////////////////////////////////////////
